home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / DONALDXC / BLESSED_.C next >
C/C++ Source or Header  |  1990-05-01  |  2KB  |  62 lines

  1. /********************************/
  2. /* File: Blessed Folder.c        */
  3. /*                                */
  4. /* Given the name of a volume    */
  5. /* in params[0]                    */
  6. /* returns the id of the         */
  7. /* blessed folder.                */
  8. /* ----------------------------    */
  9. /* Based on tech note #129        */
  10. /* by Jim Friedlander            */
  11. /********************************/
  12.  
  13. #include    <MacTypes.h>
  14. #include    <OSUtil.h>
  15. #include    <MemoryMgr.h>
  16. #include    <FileMgr.h>
  17. #include    <ResourceMgr.h>
  18. #include    <pascal.h>
  19. #include    <hfs.h>
  20. #include    <string.h>
  21. #include     "HyperXCmd.h"
  22. #include    "HyperUtils.h"
  23.  
  24. #define        nil    0L
  25.  
  26. char        colon[2] = "\p:";
  27.  
  28. pascal void main( paramPtr )
  29.     XCmdBlockPtr    paramPtr;
  30. {
  31.     long            sid;        /*** id of  blessed ("system") folder    ***/
  32.     HParamBlockRec    theHPB;        /*** needed to get the id of blessed    ***/
  33.     CInfoPBRec        theCPB;        /*** needed to reconstruct path name    ***/
  34.     char            vName[256];    /*** name of volume we're checking        ***/
  35.     char            fullPath[256];
  36.     OSErr            err;
  37.  
  38.     HLock( paramPtr->params[0] );
  39.     ZeroToPas( paramPtr, *(paramPtr->params[0]), &vName );
  40.     HUnlock( paramPtr->params[0] );
  41.  
  42.     /*** Given the name of a volume, try to get the ***/
  43.     /*** the volume reference number                 ***/
  44.     theHPB.volumeParam.ioNamePtr    = (StringPtr)vName;     
  45.     theHPB.volumeParam.ioVRefNum     = (short)0;         
  46.     theHPB.volumeParam.ioVolIndex     = -1;                 
  47.     err = PBHGetVInfo( &theHPB, 0);
  48.  
  49.     fullPath[0] = '\0';
  50.     if ( !err ){
  51.         theCPB.dirInfo.ioFDirIndex     = -1;
  52.         theCPB.dirInfo.ioDrDirID    = theHPB.volumeParam.ioVFndrInfo[0]; 
  53.         theCPB.dirInfo.ioVRefNum       = theHPB.volumeParam.ioVRefNum;        
  54.  
  55.         fullPath[0] = '\0';    
  56.         ClimbTree(    theCPB.dirInfo.ioDrDirID,(CInfoPBPtr)&theCPB,(char *)fullPath );
  57.     }
  58.     
  59.     paramPtr->returnValue = PasToZero( paramPtr, fullPath );
  60. }
  61.  
  62.